
import $store from '@/store/index.js';
import msgSqlite from "@/sqlite_services/msg.js"
//消息回执
const handle = async(data)=>{
	try{
		await msgSqlite.updateReceiptMessage({
			chat_type:data.chat_type,
			target_id:data.target_id,
			sender_id:data.reader_id,
			msg_id:data.msg_id
		},data.msg_id)
		let myid = $store.state.user.user_info.user_id
		let chat_id = data.reader_id == myid ? data.target_id : data.reader_id
		if(data.chat_type == 'group'){
			chat_id = data.target_id
		}
		const activeChatUuid = $store.state.chat.chatInfo && $store.state.chat.chatInfo.uuid || ''; // 访问根级状态的chatInfo
		if(chat_id == activeChatUuid){
			uni.$emit('onMessageControls', {
				type:'receipt',
				data
			})
		}
	}catch(e){
		console.log(e);
		throw e
	}
}
export default handle
				